package com.hanrui.android.adapter;

import android.support.v4.app.FragmentActivity;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.hanrui.android.R;
import com.hanrui.android.activity.message.MeetActivity;
import com.hanrui.android.activity.message.MyPerformanceActivity;
import com.hanrui.android.activity.message.MySuperviseActivity;
import com.hanrui.android.activity.message.MyVoteActivity;
import com.hanrui.android.activity.message.ThreeSuperviseActivity;
import com.hanrui.android.activity.performance.PerformDetailActivity;
import com.hanrui.android.activity.work.ArchivesCheckActivity;
import com.hanrui.android.model.ExpandableItem;
import com.hanrui.android.model.ExpandableLevel;
import com.hanrui.android.utils.BaseUtils;

import java.util.List;

/**
 * Created by Administrator on 2018/6/26.
 */

public class ExpandableItemAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity,BaseViewHolder> {
    private static final String TAG = ExpandableItemAdapter.class.getSimpleName();
    public static final int TYPE_LEVEL_0 = 0;
    public static final int TYPE_LEVEL_1 = 1;
    FragmentActivity context;
    public ExpandableItemAdapter(List<MultiItemEntity> data , FragmentActivity context) {
        super(data);
        addItemType(TYPE_LEVEL_0, R.layout.item_expandable_lv1);
        addItemType(TYPE_LEVEL_1, R.layout.item_expandable);
        this.context  = context;
    }




    @Override
    protected void convert(final BaseViewHolder holder, final MultiItemEntity item) {
        switch (holder.getItemViewType()) {
            case TYPE_LEVEL_0:
                final ExpandableLevel lv0 = (ExpandableLevel) item;
                holder.setText(R.id.title,lv0.title);
                break;

            case TYPE_LEVEL_1:
                final ExpandableItem lv1 = (ExpandableItem) item;
                holder.setText(R.id.car_title,lv1.name)
                .setImageResource(R.id.car_iv, BaseUtils.getImage(lv1.name));
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        switch (lv1.name){
                            case "我的会议":
                                MeetActivity.start(context,0);
                                break;
                            case "周会督办":
                                MySuperviseActivity.start(context,0);
                                break;
                            case "月会督办":
                                MySuperviseActivity.start(context,1);
                                break;
                            case "三色督办":
                                ThreeSuperviseActivity.start(context,0);
                                break;
                            case "董事会议":
                                MyVoteActivity.start(context,0);
                                break;
                            case "我的绩效":
                                MyPerformanceActivity.start(context);
                                break;
                            case "绩效查看":
                                PerformDetailActivity.start(context,"",1);
                                break;
                            case "档案查看":
                                ArchivesCheckActivity.start(context);
                                break;
                            default:
                                ToastUtils.showShort("开发中...");
                                break;
                        }
                    }
                });
                break;
        }
    }
}
